<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %>
<%@ include file="/WEB-INF/jsp/struts/taglibs.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>PIM - Personal Information Management System</title>
<!-- left menu init -->
<!-- yui begin -->
<link rel="stylesheet" type="text/css" href="../script/yui/build/fonts/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="../script/yui/build/treeview/assets/skins/sam/treeview.css" />
<script type="text/javascript" src="../script/yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="../script/yui/build/treeview/treeview-min.js"></script>
<!-- yui end -->

<script type='text/javascript' src='/dwr/interface/DWRService.js'></script>
<script type='text/javascript' src='/dwr/engine.js'></script>
<script type='text/javascript' src='/dwr/util.js'></script>

<script type="text/javascript">
    //global variable to allow console inspection of tree:
    var tree;

    //function to initialize the tree:
    function onDataFound(data) {
        buildLeftMenuTree(data);
    }

    //Function  creates the tree and 
    //builds between 3 and 7 children of the root node:
    function buildLeftMenuTree(data) {

        //instantiate the tree:
        tree = new YAHOO.widget.TreeView("leftMenuDiv");
        for ( var i = 0; i < data.length; i++) {
            var oData = new Object();
            oData.href = data[i].moduleLink;
            oData.label = data[i].moduleName;
            oData.title = data[i].description;
            var tmpNode = new YAHOO.widget.MenuNode(oData, tree
                    .getRoot(), false);
            tmpNode.collapse();
            //tmpNode.expand();
            buildLargeBranch(tmpNode,data[i].subModuleList);
        }

        // Expand and collapse happen prior to the actual expand/collapse,
        // and can be used to cancel the operation
        tree.subscribe("expand", function(node) {
            YAHOO.log(node.index + " was expanded", "info", "example");
            // return false; // return false to cancel the expand
            });

        tree.subscribe("collapse", function(node) {
            YAHOO.log(node.index + " was collapsed", "info", "example");
        });

        // Trees with TextNodes will fire an event for when the label is clicked:
        tree.subscribe("labelClick", function(node) {
            YAHOO.log(node.index + " label was clicked", "info", "example");
        });

        //The tree is not created in the DOM until this method is called:
        tree.draw();
    }

    //function builds 10 children for the node you pass in:
    function buildLargeBranch(node, subModuleList) {
        if (node.depth < 10) {
            for ( var i = 0; i < subModuleList.length; i++) {
                var oData = new Object();
                oData.href = subModuleList[i].moduleLink;
                oData.label = subModuleList[i].moduleName;
                oData.title = subModuleList[i].description;
                new YAHOO.widget.MenuNode(oData, node, false);
            }
        }
    }

    //Add an onDOMReady handler to build the tree when the document is ready

    function treeInit() {
        DWRService.getModuleList(0, onDataFound);
    }

    YAHOO.util.Event.onDOMReady(treeInit);
    window.onload=function(){
        Nifty('div#header','transparent medium'); // medium rounded corners w/transparency for gradient background image
        Nifty('div#nav,div#content,div#promo','medium same-height'); //medium rounded corners, same height cols
        Nifty('div#main_wrapper,div#footer','medium');  //medium rounded corners
        AddCss ("../style/niftyCorners.css"); // location of Nifty CSS file relative to this page
    }
</script>
<!--the layout and text stylesheets-->
<link href="../style/2_col_rounded.css" media="all" rel="stylesheet" />
<link href="../style/text_n_colors.css" media="all" rel="stylesheet" />
<script type="text/javascript"  src="script/niftycube.js"></script>
<link href="../style/drop_down_menus.css" rel="stylesheet" type="text/css" />
<link href="../style/home.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
    margin: 0;
    padding: 0;
    background: #1d1d1d;
    font-family: "Lucida Grande", Verdana, sans-serif;
    font-size: 100%;
}
#headbox {
    font-size: 0.7em;
    color:#FFF;
    text-align:right;
    padding: 20 20 0 10
}
#headbox a{
    color:#FFF;
}

#gtdbox { 
        width:473x;
        height:580px;
        overflow:hidden;
        filter:alpha(opacity=90);
        background:url(images/gtd3.gif) no-repeat; 
}
#leftMenuDiv {  
    padding: 2 2 0 1;
    font-size: 0.75em;
}

</style>

</head>

<body class="lime">
<div id="main_wrapper">

<div id="header">
    <div id="header_inner">
        <h1>个人信息管理系统 Personal Information Management System</h1>
        <div id="headbox">Welcome ${sess_user.userName},  
        ( <a href="#" onClick="javascript:window.parent.location.href='logout.htm'">Logout</a>
         | <a href="#"" onClick="javascript:window.parent.location.href='about.htm'">About</a> )
         </div>
    </div><!-- end header_inner -->
<div id="drop_down_menus">
<ul>
    <li><a href="#">首页</a></li>
    <li><a href="task.htm?method=list">任务管理</a>
         <ul>
            <li><a href="#">待处理事务</a></li>
            <li><a href="#">任务清单</a>    </li>
            <li><a href="#">日程表</a></li>
            <li><a href="#">下一步行动</a></li>
            <li><a href="#">等候清单</a></li>
            <li><a href="#">也许清单</a></li>
         </ul>
      </li>
    <li><a href="task.htm?method=list">目标管理</a>
         <ul>
            <li><a href="#">生活目标</a> </li>
            <li><a href="#">长期目标(三五年)</a></li>
            <li><a href="#">中期目标(当年)</a></li>
            <li><a href="#">短期目标(本月)</a></li>
            <li><a href="#">当前项目</a></li>
            <li><a href="#">目前工作</a></li>
         </ul>
    </li>
    <li><a href="user.htm?method=list">系统管理</a>
         <ul>
            <li><a href="#">用户管理</a>    </li>
            <li><a href="#">角色管理</a></li>
            <li><a href="#">权限管理</a></li>
            <li><a href="#">数据管理</a></li>
         </ul>
    </li>
    <li><a href="life.htm?method=list">生活管理</a>
         <ul>
            <li><a href="#">健康清单</a></li>
            <li><a href="#">维修清单</a></li>
            <li><a href="#">生日清单</a></li>
            <li><a href="#">度假清单</a></li>
            <li><a href="#">清洁清单</a></li>
            <li><a href="#">幸福感清单</a></li>
            <li><a href="#">帐号清单</a></li>
            <li><a href="#">知识库</a></li>
            <li><a href="#">通讯录</a></li>
            <li><a href="#">备忘录</a></li>
         </ul>
    </li>
    <li><a href="help.htm">帮助</a>
         <ul>
            <li><a href="#">What's GTD</a></li>
            <li><a href="#">Help</a></li>
            <li><a href="#">About</a></li>
         </ul>
    </li>
  </ul>
</div>
<div style="clear:both"></div>
</div><!-- end header -->
<div id="nav">
    <div id="nav_inner">
        <div id = "leftMenuDiv"></div>
    </div>
    
    <!-- end nav_inner -->
</div><!-- end nav -->

<div id="content">
    <div id="content_inner">
YUI Tree & DWR demo
</div></div>


<div id="footer">
     <div id="footer_inner">
      <p>Copyright &copy; 2009-2010 <a href="mailto:walter.fan@gmail.com"><em>Walter Fan</em></a> all rights reserved. </p>
    </div><!-- end footer_inner -->
</div><!-- end footer -->

</div><!--end main wrapper-->

</body>
</html>
